SYMBOLS {
    __STACKSIZE__:   type = weak,   value = $0800; # 2k stack
    __LOADADDR__:  type = import;
    __EXEHDR__:    type = import;    
	__END_OF_RAM__: type=weak, value = $D000;
	__OVERLAY_START__: type=weak, value = $8800;
	__OVERLAY_SIZE__: type=weak, value = __END_OF_RAM__ - __OVERLAY_START__;
    __EDIT_BUFFER_SIZE__: type=weak, value=$2000;
    __EDIT_BUFFER_START__: type=weak, value = __END_OF_RAM__ - __EDIT_BUFFER_SIZE__;
}
MEMORY {
    ZP:       file = "", define = yes, start = $0002, size = $001A;
    LOADADDR: file = %O,               start = $1BFF, size = $0002;
    HEADER:   file = %O,               start = $1C01, size = $000C;
    RAM:      define = yes,	start = $1C0D,				size = __OVERLAY_START__ - $1C0D - __STACKSIZE__,	file = %O;
	LOGINLA:  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.login.c128";
	LOGIN:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.login.c128"; #,	fill=yes, fillval=$ff;
	WAITLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.wait.c128";
	WAIT:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.wait.c128"; #,	fill=yes, fillval=$ff;
	MAINLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.main.c128";
	MAIN:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.main.c128"; #,	fill=yes, fillval=$ff;
	USERLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.user.c128";
	USER:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.user.c128"; #,	fill=yes, fillval=$ff;
	SUBSLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.subs.c128";
	SUBS:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__,		file = "bbs.subs.c128"; #,	fill=yes, fillval=$ff;
	EDITLA:	  define = yes, start = __OVERLAY_START__,	size = $0002,					file = "bbs.edit.c128";
	EDIT:	  define = yes, start = __OVERLAY_START__,	size = __OVERLAY_SIZE__ - __EDIT_BUFFER_SIZE__,	file = "bbs.edit.c128"; #,	fill=yes, fillval=$ff;
	TAPE:	  define = yes,	start = $1300,				size = $00BF,	fill = no,		file = "";
    STRUCTS:  define = yes, start = $1400,              size = $0400,   fill = no,      file = "";
    EDITB:    define = yes, start = __EDIT_BUFFER_START__, size = __EDIT_BUFFER_SIZE__, file = "";
    MLADDR:   file = "rs232-c128.ml", define = yes, start = $1A00, size = $0002;
    ML:       file = "rs232-c128.ml", define = yes, start = $1A00, size = $0200;
}
SEGMENTS {
    LOADADDR: load = LOADADDR, type = ro;
    EXEHDR:   load = HEADER,   type = ro;
    STARTUP:  load = RAM,      type = ro;
    LOWCODE:  load = RAM,      type = ro,                optional = yes;
    INIT:     load = RAM,      type = ro,  define = yes, optional = yes;
    CODE:     load = RAM,      type = ro;
    RODATA:   load = RAM,      type = ro;
    DATA:     load = RAM,      type = rw;
    ZPSAVE:   load = RAM,      type = bss;
    BSS:      load = RAM,      type = bss, define = yes;
    ZEROPAGE: load = ZP,       type = zp;
    STRUCTBSS: load=STRUCTS,   type = bss, define = yes;

	# OVERLAYS
	LOGINLA:	load = LOGINLA,	type = ro;
	LOGINCODE:	load = LOGIN,	type = ro,	define = yes;
	LOGINDATA:	load = LOGIN,	type = rw;
    LOGINBSS:   load = LOGIN,   type = bss, define = yes;
	WAITLA:		load = WAITLA,	type = ro;
	WAITCODE:	load = WAIT,	type = ro,	define = yes;
	WAITDATA:	load = WAIT,	type = rw;
	MAINLA:		load = MAINLA,	type = ro;
	MAINCODE:	load = MAIN,	type = ro,	define = yes;
	MAINDATA:	load = MAIN,	type = rw;
	SUBSLA:		load = SUBSLA,	type = ro;
	SUBSCODE:	load = SUBS,	type = ro,	define = yes;
	SUBSDATA:	load = SUBS,	type = rw;
    SUBSBSS:    load = SUBS,    type = bss, define = yes;
	USERLA:		load = USERLA,	type = ro;
	USERCODE:	load = USER,	type = ro,	define = yes;
	USERDATA:	load = USER,	type = rw;
    USERBSS:    load = USER,    type = bss, define = yes;
	EDITLA:		load = EDITLA,	type = ro;
	EDITCODE:	load = EDIT,	type = ro,	define = yes;
	EDITDATA:	load = EDIT,	type = rw;
    EDITBSS:    load = EDIT,    type = bss, define = yes;
    EDITBUF:    load = EDITB,   type = bss, define = yes;

	# The TAPEBUFFER segment is used to hold the user record for the 
	# currently logged in user.
	TAPEBUFFER: load=TAPE,	   type = bss, define = yes;

    MLADDR:   load = MLADDR,   type = ro;
    ML:       load = ML,       type = rw, define = yes;
}
FEATURES {
    CONDES: type    = constructor,
            label   = __CONSTRUCTOR_TABLE__,
            count   = __CONSTRUCTOR_COUNT__,
            segment = INIT;
    CONDES: type    = destructor,
            label   = __DESTRUCTOR_TABLE__,
            count   = __DESTRUCTOR_COUNT__,
            segment = RODATA;
    CONDES: type    = interruptor,
            label   = __INTERRUPTOR_TABLE__,
            count   = __INTERRUPTOR_COUNT__,
            segment = RODATA,
            import  = __CALLIRQ__;
}